checkLogin();
scorllInit();

var list_type = 1;//1表示佣金明细 2：表示提现明细
var info = getCache(login_key);
var mid = getCache(login_key).mid;
var refer_type = getCache(login_key).refer_type;

$('.member-img').attr('src',info.avatarurl);
$('#nickname').text(info.nickname);
//个人信息相关
var success = function (res) {
    var info = res.data.info;
    if(!isEmpty(info)){
        $("#total").html(info.total_money);
        $("#able").html(info.able_money);
        $("#already").html(info.already_money);
        $("#freeze").html(info.freeze_money);
    }
};
getData(member_commission,comParams(),success);


$('.to_refer').on('tap',function () {
    if (refer_type == 2) {
        redirect('refer.html?mid=' + mid);
    } else if (refer_type == 1) {
        redirect('person-refer.html?mid=' + mid);
    }
});




$('#fenye_list').empty();
fenye_options.url = commission_list;
fenye_options.params = {mid:mid};
fenye_options.dataName = 'list';
fenye_options.tmpId = 'fenye_list_data1';

var text = '您暂无佣金明细相关信息'
fenye_options.callback = function(res){
    console.log(res)
    var info = res.data.list.data;
    if(info == undefined || info == null || info == '' || info.length <=0){
        //没有数据
        var html = '<div class="no_data" style="background:#f7f7f7;align-content: center;height: ' + fenye_options.scrollHeight + ';padding-top: 50%;text-align: center;font-size: 20px;color: lightgray;">'+text+'</div>';
        $('#fenye_list').html(html)
    }else {
        var html = template(fenye_options.tmpId, res.data.list);
        var str = html.replace(/[\r\n]/g, "").replace(/\ +/g, "").trim();
        var current_page = res.data.list.current_page;
        if(!isEmpty(current_page) && current_page <= 1){
            $(fenye_options.domNode).html(html);
        }
    }

};

//选项卡切换下拉加载
mui('#segmentedControl').on('tap','a',function(e){
    var type = parseInt(this.getAttribute('data'));
    if(type == -1){
        return
    }
    window.top.location.href=this.href;
    if (list_type == type) {
        return;
    }
    list_type = type;
    page = 1;
    is_more = true;
    if(type == 1){
        fenye_options.url = commission_list;
        fenye_options.dataName = 'list';
        fenye_options.tmpId = 'fenye_list_data1';
        text = '您暂无佣金明细相关信息'
    }else if(type == 2){
        fenye_options.url = withdraw_list;
        fenye_options.dataName = 'list';
        fenye_options.tmpId = 'fenye_list_data'
        text = '您暂无提现明细相关信息'
    }else if(type == 3){
        fenye_options.url = refer_team;
        fenye_options.dataName = 'list';
        fenye_options.tmpId = 'team-list';
        text = '您暂无团队相关信息'
    }

    $('#fenye_list').empty();
    mui("#scroll").pullRefresh().enablePullupToRefresh(); //启用上拉加载控件
    mui('#scroll').pullRefresh().refresh(true); //重置上拉
    mui('#scroll').pullRefresh().endPullupToRefresh(false);//开启加载
    mui('#scroll').pullRefresh().scrollTo(0, 0, 100); //滚动到顶部
});


function scorllInit() {
    var info = getScreen();
    var slider_height = parseInt($(".mui-slider").height());
    var category_height = parseInt($("#segmentedControl").height());
    var bar_height = parseInt($(".mui-bar").height());
    var personH = parseInt($('.personal').height());
    var scroll_height = info[1] - slider_height - category_height - bar_height - personH + 'px';
    fenye_options.scrollHeight = scroll_height; //设置分页滚轴高度（自适应）
    mui('.mui-control-content').each(function() {
        this.style.height = scroll_height;
    });
    mui('.mui-scroll-wrapper').each(function(k, v) {
        mui(v).scroll({
            deceleration: (mui.os.ios ? 0.003 : 0.0006),
            indicators: false  //隐藏一条滚动条 增大减速系数。。。
        });
    });
}

$('.tixian').on('tap',function () {
    var href='applyWithdraw.html'
    redirect(href);
})





